package controller.android;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import bizlogic.BookingManager;
import model.search.BookingSearchDTO;
import model.BookingDTO;
import model.UserDTO;

/**
 * Servlet implementation class BookingStatusServlet
 */
@WebServlet("/BookingStatusServlet")
public class BookingStatusServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public BookingStatusServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub

		String id = request.getParameter("id");
		ArrayList<BookingDTO> bList = new ArrayList<BookingDTO>();

		ArrayList<String> status = new ArrayList<String>();
		status.add("Book");
		status.add("Update");

		BookingSearchDTO b = new BookingSearchDTO();
		b.setUserId(id);
		b.setStatus(status);

		BookingManager bm = new BookingManager();
		bList = bm.findBookingByCriteria(b);

		PrintWriter out = response.getWriter();



		for (int i = 0; i < bList.size(); i++) {			
			out.println( bList.get(i).getId());
			out.println( bList.get(i).getFacilityName());
			out.println( bList.get(i).getStartDate());
			out.println( bList.get(i).getEndDate());
			out.println( bList.get(i).getReason());
			out.println( bList.get(i).getEmergency());
			out.println( bList.get(i).getValidateBy());
			out.println( bList.get(i).getValidateOn());
			out.println( bList.get(i).getContactDetail());
			out.println( bList.get(i).getStatus());
			
		}
	
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
